package com.zzy.ymcc.exception;

import com.zzy.ymcc.enums.GlobalExceptionCode;
import com.zzy.ymcc.result.JSONResult;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Data
public class GlobalCustomException extends RuntimeException{

    private String errorMessage;

    private String errorCode;

    public GlobalCustomException() {
    }

    public GlobalCustomException(String message) {
        super(message);
    }

    public GlobalCustomException(String errorMessage, String errorCode) {
        super(errorMessage);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public GlobalCustomException(GlobalExceptionCode globalExceptionCode) {
        super(globalExceptionCode.getMessage());
        this.errorCode = globalExceptionCode.getCode();
        this.errorMessage = globalExceptionCode.getMessage();
    }
}
